<!-- 转正---新增 -->
<template>
    <el-dialog :title="immunityForm.id ? '修改' : '新增'" :visible.sync="dialogVisible" :show-close="false">
        <el-form ref="immunityForm" :model="immunityForm" :rules="immunityRules" label-width="110px" class="add-content">
            <el-form-item label="工号" prop="project">
                <el-input v-model="immunityForm.project" placeholder="工号" />
            </el-form-item>
            <el-form-item label="姓名" prop="project">
                <el-input v-model="immunityForm.project" placeholder="姓名" />
            </el-form-item>
            <el-form-item label="部门" prop="project">
                <el-input v-model="immunityForm.project" placeholder="部门" />
            </el-form-item>
            <el-form-item label="岗位职务" prop="project">
                <el-input v-model="immunityForm.project" placeholder="岗位职务" />
            </el-form-item>
            <el-form-item label="转正日期" prop="project">
                <el-date-picker v-model="value1" type="date" placeholder="选择日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="直管领导意见" prop="project">
                <el-input v-model="immunityForm.project" placeholder="直管领导意见" />
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="videoDisplayClose">取 消</el-button>
            <el-button type="primary" @click="submitForm('immunityForm')">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    props: {
        dialogVisible: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
            immunityForm: {
                id: '',
                time: '',
                project: '',
                object: '',
                pigsty: '',
                num: '',
                deptId: ''
            },
            immunityRules: {
                time: [
                    { required: true, message: this.$t('validate.required'), trigger: 'blur' }
                ],
                project: [
                    { required: true, message: this.$t('validate.required'), trigger: 'blur' }
                ],
                object: [
                    { required: true, message: this.$t('validate.required'), trigger: 'blur' }
                ],
                pigsty: [
                    { required: true, message: this.$t('validate.required'), trigger: 'blur' }
                ],
                num: [
                    { required: true, message: this.$t('validate.required'), trigger: 'blur' }
                ]
            },
            pigstyData: [
                {
                    value: '0',
                    label: '1舍'
                },
                {
                    value: '1',
                    label: '2舍'
                },
                {
                    value: '3',
                    label: '3舍'
                },
            ],
            epidemicPreventionTargets: [
                {
                    value: '0',
                    label: '生长猪'
                },
                {
                    value: '1',
                    label: '种猪'
                },
            ],
            value1: ''
        }
    },
    methods: {
        // 弹窗-确定按钮
        submitForm(formName) {
            //当全部验证字段通过，再开始业务逻辑
            this.$refs[formName].validate((valid) => {
                //如果全部字段符合条件
                if (valid) {
                    this.dialogVisible = false
                    //发请求（添加信息|修改信息）
                    let result = this.request(this.immunityForm);
                    // if (result.data.code === 1) {
                    //     this.$message({
                    //         type: "success",
                    //         message: this.form.id ? "修改信息成功" : "添加信息成功"
                    //     });
                    //     添加或者修改信息成功以后，再次获取信息列表
                    this.getData();
                    // }
                } else {
                    return false;
                }
            });
        },
        //把新增和编辑请求方法写一块了，根据id有无，调用不同方法
        request(form) {
            if (form.id) {
                //     return axios({
                //         method: "POST",
                //         url: "修改功能接口",
                //         data: form
                //     });
            } else {
                //     return axios({
                //         method: "POST",
                //         url: "新增功能的接口",
                //         //要提交的数据
                //         data: {
                //             yearquarter: 202204,
                //             post: this.form.item,
                //             item: this.form.item,
                //             description: this.form.item,
                //             kpiorcpi: this.form.item,
                //             goalortask: this.form.item,
                //             weight: this.form.item
                //         }
                //     });
            }
        },
        // 关闭事件
        videoDisplayClose() {
            this.$emit('sendFVideo', false)
        }
    }
}
</script>

<style scoped>
.add-content{
    
}
</style>